package com.amado.course36ByteStream;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class S09BufferOutStream {
	public static void main(String[] args) throws IOException {
		//每次从达到10字节，才刷新缓冲区的内容到文件 
		BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("d:/123.txt"), 10);
		byte[] data = new byte[] {'A','A','A','A'};
		//从缓冲区读取数据，如果缓存区已读取完，缓存区再从文件读取1024个字节
		int i=0;
		while(i<6) {
			out.write(data);
			//不推荐每次刷新
			//out.flush();
			i++;
		}
		//close时会手功刷新缓存区的数据到文件
		out.close();
	}
}
